-- 该mod是蘑菇慕斯私有修改mod，该模组未获得原作者版权，所以请勿搬运
-- 该mod依靠某个BUG运行，请勿修改


local TheInput = GLOBAL.TheInput
local require = GLOBAL.require
TUNING.UNIT = GetModConfigData("sw_shizhong_UNIT") or "T"
local ent_util = require("libs/entutil")
-- 语言

-- 导入宣告表
local LANGUAGE = "chinese"
modimport("languages/Announces_cn.lua")

for k,v in pairs(ANNOUNCE_STRINGS) do
	if k ~= "UNKNOWN" and k ~= "_" and GetModConfigData(k) == false then
		ANNOUNCE_STRINGS[k] = ANNOUNCE_STRINGS.UNKNOWN
	end
end

-- 合并宣告字符，在其他mod前加载
if type(GLOBAL.STRINGS._STATUS_ANNOUNCEMENTS) == "table" then
	for k,v in pairs(GLOBAL.STRINGS._STATUS_ANNOUNCEMENTS) do
		ANNOUNCE_STRINGS[k] = v;
	end
end
ANNOUNCE_STRINGS._.LANGUAGE = LANGUAGE -- 翻译，慕斯不管这个

--表情
ANNOUNCE_STRINGS._.STAT_EMOJI = {
	Hunger = "hunger",
	Sanity = "sanity",
	Health = "heart",
	Abigail = "abigail",
	Flex = "flex",
	Battle = "battle",
	Boat = "salt",
	Stamina = "refine",
	Spellpower = "redgem",
	Electric = "lightbulb",
	Bloom = "carrot",
	Magic = "refine",
}
-- 将宣告的句子放在全局的表中，让别的mod也能修改
GLOBAL.STRINGS._STATUS_ANNOUNCEMENTS = ANNOUNCE_STRINGS

-- 适配熔炉
if GLOBAL.TheNet:GetServerGameMode() == "lavaarena" then
	GLOBAL.STRINGS._STATUS_ANNOUNCEMENTS.WOODIE = GLOBAL.STRINGS._STATUS_ANNOUNCEMENTS.WOODIE.HUMAN
end

local StatusAnnouncer = require("statusannouncer")()

--实际上需要这个在本地添加控制器按钮提示
local OVERRIDEB =  GetModConfigData("shizhong_SHOWWORLDTEMP")
local boki = GetModConfigData("xuangao_saobao")
local only = GetModConfigData("xuangao_self")
local wandahealthy = GetModConfigData("sw_wanda") and (GetModConfigData("wanda_display") == true)
local OVERRIDESELECT = "Clock"
StatusAnnouncer:SetLocalParameter("WHISPER", GetModConfigData("xuangao_WHISPER"))
StatusAnnouncer:SetLocalParameter("WHISPER_ONLY", false)
StatusAnnouncer:SetLocalParameter("EXPLICIT", true)
StatusAnnouncer:SetLocalParameter("OVERRIDEB", OVERRIDEB)
StatusAnnouncer:SetLocalParameter("OVERRIDESELECT", OVERRIDESELECT)
StatusAnnouncer:SetLocalParameter("SHOWDURABILITY", true)
StatusAnnouncer:SetLocalParameter("SHOWPROTOTYPER", true)
StatusAnnouncer:SetLocalParameter("SHOWEMOJI", true)
StatusAnnouncer:SetLocalParameter("boki", boki)
StatusAnnouncer:SetLocalParameter("wandahealthy", wandahealthy)

local PlayerHud = require("screens/playerhud")
local PlayerHud_SetMainCharacter = PlayerHud.SetMainCharacter
function PlayerHud:SetMainCharacter(maincharacter, ...)
	PlayerHud_SetMainCharacter(self, maincharacter, ...)
	self._lock_huxi = true					-- 与其他版本兼容
	self._StatusAnnouncer = StatusAnnouncer
	if maincharacter then
		--Note that this also clears out the stats and cooldowns, so we have to re-register them
		StatusAnnouncer:SetCharacter(maincharacter.prefab)
		StatusAnnouncer:RegisterCommonStats(self, maincharacter.prefab)
	end
end
local PlayerHud_OnMouseButton = PlayerHud.OnMouseButton
function PlayerHud:OnMouseButton(button, down, ...)
	if button == 1000 and down and TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) then
		if StatusAnnouncer:OnHUDMouseButton(self) then
			return true
		end
	end
	if type(PlayerHud_OnMouseButton) == "function" then
		return PlayerHud_OnMouseButton(self, button, down, ...)
	end
end


local function find_season_badge(HUD)
	HUD = HUD or GLOBAL.ThePlayer.HUD
	if HUD.controls.seasonclock then
		return HUD.controls.seasonclock, "Clock"
	elseif HUD.controls.season then -- actually needs to get checked before Compact because they both get attached to status
		return HUD.controls.season, "Micro"
	elseif HUD.controls.status.season then
		return HUD.controls.status.season, "Compact"
	end
end

local newCraftSlot = require("widgets/redux/craftingmenu_hud")
local newCraftSlot_OnControl = newCraftSlot.OnControl
function newCraftSlot:OnControl(control, down, ...)
	if TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) and 
	down and control == GLOBAL.CONTROL_ACCEPT
	then
		if self.pinbar and self.pinbar.focus then
			return StatusAnnouncer:newAnnouncePinbar(self.pinbar)
		end
		if self.craftingmenu and self.craftingmenu.focus and self.craftingmenu.enabled then 
			local menu = self.craftingmenu
			if menu.details_root and menu.details_root.shown and menu.details_root.focus then
				return StatusAnnouncer:newAnnounceDetail(menu.details_root)
			end
			if menu.recipe_grid and menu.recipe_grid.shown and menu.recipe_grid.focus then
				return StatusAnnouncer:newAnnounceGrid(menu.recipe_grid)
			end
			if menu.filter_panel and menu.filter_panel.shown and menu.filter_panel.focus then
				-- 暂时不适配，因为官方无官中
				-- 有官中了，但是没啥好想法，先鸽子了

				-- 还是没啥想法，宣告这个如何：
				-- 你要找的东西在【食物和耕种】一栏。

				-- 写了写了，就在下面 不过是右键宣告
			end
		end
	elseif TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT)
		and control == GLOBAL.CONTROL_SECONDARY and down 
		and self.craftingmenu and self.craftingmenu.focus and self.craftingmenu.enabled then
			local menu = self.craftingmenu
			if menu.recipe_grid and menu.recipe_grid.shown and menu.recipe_grid.focus then
				local panels = menu.filter_panel and menu.filter_panel.filter_grid and menu.filter_panel.filter_grid.children
				if type(panels) == "table" then
					for panel in pairs(panels)do
						if type(panel.children) == "table" then
							for btn in pairs(panel.children)do
								if type(btn) == "table" and btn.selected then
									local text = panel.hovertext and panel.hovertext:GetString()
									if text and text~="" then
										return StatusAnnouncer:newAnnounceGrid(menu.recipe_grid, text)
									end
								end
							end
						end
					end
				end			
			end
	elseif not TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) then
		return newCraftSlot_OnControl(self, control, down, ...)
	end
end



--宣告库存,阻止宣告时制作 - 旧版
for _,classname in pairs({"invslot", "equipslot"}) do
	local SlotClass = require("widgets/"..classname)
	local SlotClass_OnControl = SlotClass.OnControl
	function SlotClass:OnControl(control, down, ...)
		if down and control == GLOBAL.CONTROL_ACCEPT
			and TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT)
			and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT)
			then
			if self.tile then
				return StatusAnnouncer:AnnounceItem(self)
			else
				return StatusAnnouncer:AnnounceSpace(self)
			end
		else
			return SlotClass_OnControl(self, control, down, ...)
		end
	end
end

-- 宣告礼物
AddClassPostConstruct("widgets/giftitemtoast", function(self)
	local _OnMouseButton = self.OnMouseButton
	function self:OnMouseButton(button, down, ...)
		local ret = _OnMouseButton(self, button, down, ...)
		if button == GLOBAL.MOUSEBUTTON_LEFT and down and TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) then
			StatusAnnouncer:Announce(self.enabled
								and ANNOUNCE_STRINGS._.ANNOUNCE_GIFT.CAN_OPEN
								or ANNOUNCE_STRINGS._.ANNOUNCE_GIFT.NEED_SCIENCE)
		end
	end
end)

local tonumber = GLOBAL.tonumber
local function getHP(ent)
	local HUD_cs = GLOBAL.ThePlayer.HUD.controls
	local metadata, hea_cur, hea_all, str
	if HUD_cs then
		if HUD_cs.hover then
			local hover = HUD_cs.hover
			-- Insight
			if hover.insightText then
				str = hover.insightText.raw_text
				if str then
					hea_cur, hea_all = str:match("HEALTH>(%-?%d+%.*%d*)</color> / <color=HEALTH>(%-?%d+%.*%d*)")
				end
			-- ShowMe
			elseif hover.text then
				str = HUD_cs.hover.text:GetString()
				hea_cur, hea_all = str:match("(%-?%d+%.*%d*) / (%-?%d+%.*%d*)")
			end
		end
		
		if not hea_cur or not hea_all then
			-- DYC血条
			if ent.dychealthbar then
				str = ent.dychealthbar
				hea_cur, hea_all = str.dychp_net:value(), str.dychpmax_net:value()
			-- Epic血条
			elseif HUD_cs.epichealthbar then
				str = HUD_cs.epichealthbar
				if str.name_text and str.name_text:GetString() == ent.name and str.currenthealth_text and str.maxhealth_text then
					hea_cur, hea_all = str.currenthealth_text:GetString():gsub(",",""), str.maxhealth_text:GetString():gsub(",","")
				end
			end
		end
		if tonumber(hea_cur) and tonumber(hea_all) then
			metadata = {
				hea_cur = string.format("%.f", hea_cur),
				hea_all = string.format("%.f", hea_all),
			}
		end
	end
	return metadata
end
local ModifyWords = {
	rock2 = "金矿",
	sapling_moon = "月岛树苗",
}
local function GetSpiceName(name)
	local spice = name:match("spice_(.+)")
	if spice then
		local of_name = GLOBAL.STRINGS.NAMES["SPICE_"..spice:upper().."_FOOD"]
		if of_name then
			return of_name:match("(.+){food}")
		end
	end
end

local function GetDisPlayName(prefab, ent)
	if not ent then return GLOBAL.STRINGS.NAMES[prefab:upper()] end
	local name = GLOBAL.STRINGS.NAMES[prefab:upper()] or ent:GetBasicDisplayName()

	if name == "MISSING NAME"  then
		name = prefab
	end
	if ANNOUNCE_STRINGS.__.ANNOUNCE_MODIFY and ANNOUNCE_STRINGS.__.ANNOUNCE_MODIFY[prefab] then
		name = ModifyWords[prefab]
	end
	return name
end

-- 种植宽松的植物
local loose_plants = {"lureplant", "bullkelp_plant"}
-- 无需采摘的植物
local npick_plants = {"bambootree", "bush_vine", "lureplant"}
-- 同屏宣告
local cooldown = false
AddComponentPostInit("playercontroller", function(self, inst)
    if inst ~= GLOBAL.ThePlayer then return end
    local PlayerControllerOnControl = self.OnControl
    self.OnControl = function(self, control, down, ...)
        if InGame() and not cooldown
		and down 
		and control == GLOBAL.CONTROL_PRIMARY -- 左键点击
		and TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) -- 键盘ALT
		and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) -- 键盘SHIFT
		and not TheInput:GetHUDEntityUnderMouse() -- 鼠标下不是HUD
		then
			cooldown = GLOBAL.ThePlayer:DoTaskInTime(1, function()
				cooldown = false		-- 1秒的内置CD，万一有人卡键就不会卡死
			end)

			local ent = TheInput:GetWorldEntityUnderMouse()
			if ent and ent.prefab then
				local prefab = ent.prefab
				print(prefab)
				if ent == GLOBAL.ThePlayer then
					return PlayerControllerOnControl(self, control, down, ...)
				end
				local activedata
				local prefabCount = getPrefabCount(prefab)
				if ent:HasTag("player") and ent.name then
					if GLOBAL.ThePlayer.replica.inventory then
						local active_item = GLOBAL.ThePlayer.replica.inventory:GetActiveItem()
						if active_item and active_item.name then
							activedata = {
								name = active_item.name,
								count = getStacksize(active_item),
							}
						end
					end
					return StatusAnnouncer:AnnouncePeople(ent, activedata)
				end

				local displayName = GetDisPlayName(prefab, ent)
				if ent:HasTag("fire") and not ent:HasTag("campfire") and not ent:HasTag("tree") then
					if prefab == "houndfire" then
						displayName = ""
					end
					return StatusAnnouncer:AnnounceFire(displayName)
				elseif ent:HasTag("burnt") and ent:HasTag("structure") then
					return StatusAnnouncer:AnnounceBurnt(displayName)
				elseif prefab == "townportal" then
					return StatusAnnouncer:AnnouncePortal(displayName, SearchForAnim({"idle_on_loop"}, ent))
				elseif prefab == "deer" then
					local has = getPrefabCount(prefab, nil, nil, nil, nil, nil, nil, function(ent)
						return ent and ent.AnimState and ent.AnimState:GetSymbolOverride("swap_antler_red")
					end)
					if has > 0 then
						return StatusAnnouncer:AnnounceDeer(displayName, has, prefabCount)
					end
				elseif table.contains({"marbleshrub", "spiderden"}, prefab) and SearchForAnim({"idle_tall", "cocoon_large"}, ent) then
					return StatusAnnouncer:AnnounceSpiderden(displayName, getPrefabCount(prefab, nil, nil, nil, {"idle_tall", "cocoon_large"}), prefabCount)
				elseif (ent:HasTag("plant") or ent:HasTag("planted") or ent:HasTag("kelp")) 
					and (not ent:HasTag("tree"))
					and (not ent:HasTag("farm_plant")) 
					and getPrefabCount(prefab, 10, nil, nil, nil, nil, ent:GetPosition()) > (table.contains(loose_plants, prefab) and 3 or 9)
					then
						local stat = "作物状态"
						local count = 0
						local canpick = "pickable"
						local needfertilization = "witherable"

						if ent:HasTag(canpick) or (table.contains(npick_plants, prefab) and SearchForAnim(ANNOUNCE_STRINGS.__.ANNOUNCE_PLANT.IDLE_STAT, ent)) then
							stat = "IDLE"
							count = getPrefabCount(prefab, nil, (not table.contains(npick_plants, prefab)) and {canpick}, nil, ANNOUNCE_STRINGS.__.ANNOUNCE_PLANT.IDLE_STAT)
						elseif ent:HasTag(needfertilization) and  SearchForAnim(ANNOUNCE_STRINGS.__.ANNOUNCE_PLANT.DEAD_STAT, ent) then
							stat = "DEAD"
							count = getPrefabCount(prefab, nil, {"witherable"}, nil, ANNOUNCE_STRINGS.__.ANNOUNCE_PLANT.DEAD_STAT)
						else
							count = prefabCount
						end
					-- 这里共移植了 15 个草，其中 10 个还没施肥。
					return StatusAnnouncer:AnnouncePlant(
						displayName, 
						stat,
						prefabCount, 
						count
					)
				elseif ent:HasTag("farm_plant") and prefabCount > 1 then
					local stat
					local count = 0
					-- 我这种了 15 颗火龙果藤，其中 5 颗已经成熟
					-- 我种了 15 颗火龙果藤，其中 3 颗还是种子
					local anim = GetAnim(ent)
					if anim then
						if anim == "crop_seed" then
							stat = "seed"
							count = getPrefabCount(prefab, nil, {"farm_plant"}, nil, anim)
						elseif table.contains({"crop_sprout", "crop_small", "crop_med"}, anim) then
							stat = "grow"
							count = getPrefabCount(prefab, nil, {"farm_plant"}, nil, {"crop_sprout", "crop_small", "crop_med"})
						elseif anim == "crop_full" then
							stat = "full"
							count = getPrefabCount(prefab, nil, {"farm_plant"}, nil, anim)
						elseif anim == "crop_oversized" then
							stat = "over"
							count = getPrefabCount(prefab, nil, {"farm_plant"}, nil, anim)
						elseif table.contains({"crop_rot", "crop_rot_oversized"}, anim) then
							stat = "rot"
							count = getPrefabCount(prefab, nil, {"farm_plant"}, nil, {"crop_rot", "crop_rot_oversized"})
						end
						if stat then
							return StatusAnnouncer:AnnounceCrop(
								displayName, 
								stat,
								prefabCount,
								count
							)
						end
					end


				elseif prefab == "terrarium" then
					if(ent:HasTag("trader") or ent:HasTag("alltrader")) then
						displayName = displayName.. "（未" .. STRINGS.ACTIONS.ACTIVATE.GENERIC.."）"
					else
						displayName = displayName.. "（已" .. STRINGS.ACTIONS.ACTIVATE.GENERIC.."）"
					end
				elseif ent:HasTag("stewer") and ent.AnimState then
					if SearchForAnim({"idle_full",}, ent) then
						local b, food_symbol = ent.AnimState:GetSymbolOverride("swap_cooked")
						local b2, spice_symbol = ent.AnimState:GetSymbolOverride("swap_garnish")
						local true_food_name,metadata
						if food_symbol then
							for k in pairs(GLOBAL.Prefabs)do
								if GLOBAL.hash(k) == food_symbol then
									local foodcopy = ent_util:ClonePrefab(k)
									metadata = foodcopy and foodcopy.components.edible
									true_food_name = GetDisPlayName(k)
									break
								end
							end
						end
						if true_food_name and spice_symbol then
							for _,name in pairs({"spice_garlic", "spice_sugar", "spice_chili", "spice_salt"})do
								if GLOBAL.hash(name) == spice_symbol then
									local food_name = GetSpiceName(name)
									if food_name then
										true_food_name = food_name..true_food_name
										if name == "spice_salt" and metadata then
											metadata._huxi_salt = true
										end
										break
									end
								end
							end
						end
						if true_food_name and metadata then
							return StatusAnnouncer:AnnounceFood(displayName, true_food_name, metadata)
						end
					elseif SearchForAnim({"cooking_loop","cooking_pst"}, ent) then
						return StatusAnnouncer:AnnounceCooking(displayName, ent._huxi_ann_data)
					end
				elseif prefab == "beebox" and SearchForAnim({"honey1", "honey2", "honey3"}, ent) and prefabCount > 1 then
					return StatusAnnouncer:AnnounceHoney(displayName, 
						prefabCount, 
						getPrefabCount(prefab, nil, nil, nil, {"honey3"}), 
						getPrefabCount(prefab, nil, nil, nil, {"honey1", "honey2", "honey3"}),
						SearchForAnim({"honey3"}, ent)
					)
				elseif prefab == "meatrack" and prefabCount > 1 then
					local anim = GetAnim(ent)
					if anim and table.contains({"idle_full", "drying_loop"}, anim) then
						return StatusAnnouncer:AnnounceMeatrack(displayName, 
							prefabCount, --all
							getPrefabCount(prefab, nil, nil, nil, {"idle_full"}), 
							getPrefabCount(prefab, nil, nil, nil, {"drying_loop", "idle_full"}),
							anim == "idle_full"
						)
					end
				elseif string.find(prefab, "deer_antler") then
					return StatusAnnouncer:AnnounceCount(getPrefabCount({"deer_antler","deer_antler1","deer_antler2","deer_antler3"}, nil, nil, {'FX','DECOR','NOCLICK', 'player'}), 
					displayName)
				elseif table.contains({"blueprint", "sketch"}, prefab) and prefabCount>1 then
					return StatusAnnouncer:AnnouncePaper(prefabCount,ent:HasTag("sketch"),ent:GetBasicDisplayName())
				elseif ent:HasTag("tree") and SearchRegularAnim("tall", ent) then
					return StatusAnnouncer:AnnounceTree(prefabCount, displayName, getPrefabCount(prefab, nil, nil, nil, nil, nil, nil, function(e)
						return SearchRegularAnim("tall", e)
					end))
				end

				if ent:HasTag("_inventoryitem") then
					local ent_pos = ent.Transform and ent:GetPosition()
					local player_pos = GLOBAL.ThePlayer.Transform and GLOBAL.ThePlayer:GetPosition()
					if ent_pos and player_pos then
						local count = getPrefabCount(prefab, 4)
						if GetDist(ent_pos.x, ent_pos.z, player_pos.x, player_pos.z) < 3 and count ~= 0 then
							return StatusAnnouncer:AnnounceHere(displayName, count)
						end
					end
				end

				return StatusAnnouncer:AnnounceCount(only and prefabCount or getPrefabCount(prefab, nil, nil, {'FX','DECOR','NOCLICK', 'player'}), 
					displayName, 
					getHP(ent)
				)
			else
				local pos = TheInput:GetWorldPosition()
				local ents = pos and GLOBAL.TheSim:FindEntities(pos.x, 0, pos.z, 16, nil, {'INLIMBO', 'player'})
				if type(ents) == "table" then
					for _, ent in pairs(ents) do
						if ent:HasTags({"oceanfishable", "oceanfishinghookable"}) then
							local str = GLOBAL.STRINGS.UI.OBJECTOWNERSHIP
							local adj = GLOBAL.STRINGS.UI.CUSTOMIZATIONSCREEN.OCEAN_SHOAL
							local name = str and adj and GLOBAL.subfmt(str, {owner = ent.name, object = adj})
							return name and StatusAnnouncer:AnnounceCount(1, name)
						elseif ent:HasTags({"antlion_sinkhole","antlion_sinkhole_blocker"}) then
							return StatusAnnouncer:AnnounceCount(1, "地陷深"..ent.name)
						elseif ent.prefab == "icefishing_hole" then
							return StatusAnnouncer:AnnounceCount(1, "冰钓之洞")
						end
					end
				end
			end
        end
        return PlayerControllerOnControl(self, control, down, ...)
    end
end)
local __ConfirmExecutionOnceTheLock
AddClassPostConstruct("screens/playerhud", function(self)
	local __OpenContainer = self.OpenContainer
	self.OpenContainer = function(HUD, ent, ...)
		local sult = __OpenContainer(HUD, ent, ...)
		if __ConfirmExecutionOnceTheLock then return sult end
		local container = ent_util:GetContainer(ent)
		if container and ent:HasTag("stewer") then
			local widget = container:GetWidget()
			local _fn = widget and widget.buttoninfo and widget.buttoninfo.fn
			if _fn then
				__ConfirmExecutionOnceTheLock = true
				widget.buttoninfo.fn = function(ent, ...)
					local foods = self.controls and self.controls.foodcrafting and self.controls.foodcrafting.selfoods
					if type(foods) == "table" then
						local metadata = {}
						local cooktime = 1
						for _,food in pairs(foods)do
							local recipe = food and food.recipe
							if type(food) == "table" and type(recipe)=="table" and type(recipe.cooktime)=="number" then
								table.insert(metadata, {
									name = food.localized_name,
									hea = recipe.health,
									san = recipe.sanity,
									hun = recipe.hunger
								})
								cooktime = (cooktime > recipe.cooktime) and cooktime or recipe.cooktime
							end
						end
						cooktime = (ent:HasTag("mastercookware") and GLOBAL.TUNING.PORTABLE_COOK_POT_TIME_MULTIPLIER or 1)
							* cooktime * GLOBAL.TUNING.BASE_COOK_TIME
						-- print("cooktime",cooktime)
						ent._huxi_ann_data = metadata
						GLOBAL.ThePlayer:DoTaskInTime(cooktime, function()
							if ent then
								ent._huxi_ann_data = nil
							end
						end)
					end
					return _fn(ent, ...)
				end
			end
		end
		return sult
	end
end)






-- 建材宣告
AddClassPostConstruct("widgets/containerwidget", function(self, owner)
	local _OnControl = self.OnControl
	self.OnControl = function(self, control, down, ...)
		if TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) and 
		down and control == GLOBAL.CONTROL_ACCEPT
		and type(self.children) == "table"
		then
			local act_str,name,need,all
			for item in pairs(self.children)do
				if type(item) == "table" then
					if item.text then
						act_str = type(item.name) == "string" and item.name
					elseif item.focus and type(item.children)=="table" then
						local prefab = item.bgimage2 and item.bgimage2.texture:match('[^/]+$'):gsub('%.tex$', '')
						name = prefab and GetDisPlayName(prefab)
						for wig in pairs(item.children)do
							if type(wig) == "table" and wig.font and type(wig.string)=="string" then
								local a,b = string.match(wig.string,"(%d+)/(%d+)")
								need, all = GLOBAL.tonumber(a),GLOBAL.tonumber(b)
								if need and all then
									need = all - need
								end
								break
							end
						end
					end
				end
			end
			if act_str and name and need and all then
				local build = PlayerFindEnt(nil, 20, {"constructionsite"})
				if build then
					return StatusAnnouncer:AnnounceBuild(act_str, GetDisPlayName(build.prefab, build), all, need, name)
				end
			end
		end
		return _OnControl(self, control, down, ...)
	end
end)



-- 哼，不加了
-- local t_util = require "libs/tableutil"
-- -- 技能树宣告
-- AddClassPostConstruct("widgets/redux/skilltreewidget", function(self)
-- 	local _OnControl = self.OnControl
-- 	self.OnControl = function(self, control, down, ...)
-- 		if TheInput:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) and 
-- 		down and control == GLOBAL.CONTROL_ACCEPT and self.root then
-- 			local st = t_util:GetChild(self.root, "SkillTreeBuilder")
-- 		end
-- 		return _OnControl(self, control, down, ...)
-- 	end
-- end)